﻿package mortal.common.swfPlayer.data
{

    public class DirectionType extends Object
    {
        private static var _directionMap:Object = {1:"南", 2:"西南", 3:"西", 4:"西北", 5:"北", 6:"东北", 7:"东", 8:"东南"};
        private static var _sideMap:Object = {1:"下", 2:"左下", 3:"左", 4:"左上", 5:"上", 6:"右上", 7:"右", 8:"右下"};
        private static var _directionRotation:Object = {1:180, 2:-135, 3:-90, 4:-45, 5:0, 6:45, 7:90, 8:135};
        private static var _dirXTurn:Object = {1:-1, 2:8, 3:7, 4:6, 5:-1, 6:4, 7:3, 8:2};
        private static var _dirYTurn:Object = {1:5, 2:4, 3:-1, 4:2, 5:1, 6:8, 7:-1, 8:6};
        public static const South:int = 1;
        public static const SouthWest:int = 2;
        public static const West:int = 3;
        public static const NorthWest:int = 4;
        public static const North:int = 5;
        public static const NorthEast:int = 6;
        public static const East:int = 7;
        public static const SouthEast:int = 8;
        public static const DefaultDir:int = 1;

        public function DirectionType()
        {
            return;
        }// end function

        public static function isPositive(param1:int) : Boolean
        {
            return param1 < 3 || param1 == SouthEast;
        }// end function

        public static function getDirction(param1:int) : String
        {
            return _directionMap[param1];
        }// end function

        public static function getSide(param1:int) : String
        {
            return _sideMap[param1];
        }// end function

        public static function getRotation(param1:int) : int
        {
            return _directionRotation[param1];
        }// end function

        public static function getXTurnDir(param1:int) : int
        {
            return _dirXTurn[param1];
        }// end function

        public static function getYTurnDir(param1:int) : int
        {
            return _dirYTurn[param1];
        }// end function

        public static function turnLeft(param1:int) : int
        {
            param1 = param1 + 1;
            if (param1 > 8)
            {
                param1 = South;
            }
            return param1;
        }// end function

        public static function turnRight(param1:int) : int
        {
            param1 = param1 - 1;
            if (param1 <= 0)
            {
                param1 = SouthEast;
            }
            return param1;
        }// end function

    }
}
